Xbasic

YEAR Function

IN THIS PAGE

Syntax

Year as N = YEAR( Date as D )

Year as N = YEAR( Date_Time as T )

Arguments

date

A variable containing a date value or a character string containing a legitimate representation of a date value ( ISDATE (Date_Value) = .T.).

Date_Time

A variable containing a date-time value (type T).

Returns

YearNumeric

Returns the full year for the specified date.

Description

Returns a four digit integer equal to the year portion of the specified Date or Date_Time value.

Discussion

Example

If START contains 05/25/1995.

? year(START)
= 1995
? year(date() )
= 2006
? year(now() )
= 2006

Two Digit Years

If the date specifies the year using two digits, the YEAR() function will assume the date to be in the 20th century if it is on or after '00' to an upper bound defined in the Settings for Alpha Anywhere.

For example:

? year({10/20/30})
= 1930

? year({01/02/03})
= 2003

You can change the upper bound for two digit years assumed to be 21st century years in the Alpha Anywhere Development Environment settings. Under the View menu, select Settings. Open the Date settings and change the upper bound for two digit years assumed to be 21st century years.

You can optionally require all years to be 4 digit years in dates by checking Require all years to be fully specified.

images/yearSetting.png

See Also